#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"

const ll inf=0x3f3f3f3f;

void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    vector<ll>b(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    ll l=0,r=1e9,ans=inf;
    while(l<=r){
        ll mid=(l+r)>>1;
        ll minn=-inf;
        ll maxn=inf;
        int flag=1;
        for(int i=0;i<n;i++){
            ll xiao=a[i]-mid*b[i];
            ll da=a[i]+mid*b[i];
            minn=max(minn,xiao);
            maxn=min(da,maxn);
            if(minn>maxn){
                flag=0;
                break;
            }
        }
        if(flag){
            ans=mid;
            r=mid-1;
        }
        else {
            l=mid+1;
        }
    }
    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int _=1;
    cin>>_;
    while(_--){
        solve();
    }
    return 0;
}